package com.neusoft.neuiotms.dcam.workflow.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.auth.common.bean.UserBean;
import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.neuiotms.dcam.workflow.dto.ITSMApproveDTO;
import com.neusoft.neuiotms.dcam.workflow.dto.RukuKJDTO;
import com.neusoft.neuiotms.dcam.workflow.service.RukuKJService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "科技公司物资入库工单")
@RestController
@RequestMapping(value = "/api/w/workflow/rukukj")
public class RukuKJController {

    @Autowired
    private RukuKJService rukuKJService;

    @ApiOperation("新增物资入库申请")
    @PostMapping
    public ResultDTO<RukuKJDTO> create(@RequestBody final RukuKJDTO dto,
            final UserBean user) {
        return ResultDTO.success(this.rukuKJService.create(dto, user));
    }

    @ApiOperation("查看物资入库申请")
    @GetMapping("/{workOrderNum}/{taskId}")
    public ResultDTO<RukuKJDTO> details(@PathVariable final String workOrderNum,
            @PathVariable final String taskId,
            final UserBean user) {
        return ResultDTO.success(this.rukuKJService.detail(workOrderNum, taskId, user));
    }

    @ApiOperation("ITSM审批")
    @PostMapping("itsm")
    public ResultDTO<ITSMApproveDTO> itsmCreate(@RequestBody final ITSMApproveDTO dto,
            final UserBean user) {
        return ResultDTO.success(this.rukuKJService.itsmCreate(dto, user));
    }

    @ApiOperation("查看ITSM审批")
    @GetMapping("itsm/{workOrderNum}/{taskId}")
    public ResultDTO<ITSMApproveDTO> itsmDetails(@PathVariable final String workOrderNum,
            @PathVariable final String taskId,
            final UserBean user) {
        return ResultDTO.success(this.rukuKJService.itsmDetails(workOrderNum, taskId, user));
    }

    @ApiOperation("新增科技公司流程确认节点")
    @PostMapping("/confirm")
    public ResultDTO<ITSMApproveDTO> create(@RequestBody final ITSMApproveDTO dto, final UserBean user) {
        return ResultDTO.success(this.rukuKJService.confirm(dto, user));
    }
}
